package cn.Filter;

import javax.servlet.*;
import java.io.IOException;

public class CharEncoding implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        System.out.println("开始初始化");

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
        request.setCharacterEncoding("utf-8");
        filterChain.doFilter(request,response);
        response.setCharacterEncoding("utf-8");

    }

    @Override
    public void destroy() {
        System.out.println("销毁");

    }
}
